package cn.wolfcode.trip.base.domain;

import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class News extends BaseDomain {
    public static final int NEWS_COMMON = 0;//草稿
    public static final int NEWS_RELEASE = 1;//发布
    public static final int NEWS_HOT = 2;//草稿
    //封面
    private String coverUrl;
    //标题
    private String title;
    //创建时间
    private Date createTime;
    //发布时间
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date releaseTime;
    //是否发布
    private boolean isRelease;
    //类型
    private NewsType type;
    //状态
    private int state;
    //摘要
    private String abstracts;
    //日报内容
    private NewsContent details;

    public String getJsonString(){
        HashMap<Object, Object> map = new HashMap();
        map.put("id", id);
        map.put("title", title);
        map.put("abstracts", abstracts);
        map.put("coverUrl", coverUrl);
        if(type != null){
            map.put("typeId",type.getId());
        }
        return JSON.toJSONString(map);
    }
}